// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.

#![allow(rustdoc::redundant_explicit_links)]
#![allow(rustdoc::broken_intra_doc_links)]
#![no_implicit_prelude]
extern crate bytes;
extern crate serde;
extern crate serde_json;
extern crate serde_with;
extern crate std;
extern crate wkt;

mod debug;
mod deserialize;
mod serialize;

/// The POSIX account information associated with a Google account.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct PosixAccount {
    /// Only one POSIX account can be marked as primary.
    pub primary: bool,

    /// The username of the POSIX account.
    pub username: std::string::String,

    /// The user ID.
    pub uid: i64,

    /// The default group ID.
    pub gid: i64,

    /// The path to the home directory for this account.
    pub home_directory: std::string::String,

    /// The path to the logic shell for this account.
    pub shell: std::string::String,

    /// The GECOS (user information) entry for this account.
    pub gecos: std::string::String,

    /// System identifier for which account the username or uid applies to.
    /// By default, the empty value is used.
    pub system_id: std::string::String,

    /// Output only. A POSIX account identifier.
    pub account_id: std::string::String,

    /// The operating system type where this account applies.
    pub operating_system_type: crate::model::OperatingSystemType,

    /// Output only. The canonical resource name.
    pub name: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl PosixAccount {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [primary][crate::model::PosixAccount::primary].
    pub fn set_primary<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.primary = v.into();
        self
    }

    /// Sets the value of [username][crate::model::PosixAccount::username].
    pub fn set_username<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.username = v.into();
        self
    }

    /// Sets the value of [uid][crate::model::PosixAccount::uid].
    pub fn set_uid<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
        self.uid = v.into();
        self
    }

    /// Sets the value of [gid][crate::model::PosixAccount::gid].
    pub fn set_gid<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
        self.gid = v.into();
        self
    }

    /// Sets the value of [home_directory][crate::model::PosixAccount::home_directory].
    pub fn set_home_directory<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.home_directory = v.into();
        self
    }

    /// Sets the value of [shell][crate::model::PosixAccount::shell].
    pub fn set_shell<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.shell = v.into();
        self
    }

    /// Sets the value of [gecos][crate::model::PosixAccount::gecos].
    pub fn set_gecos<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.gecos = v.into();
        self
    }

    /// Sets the value of [system_id][crate::model::PosixAccount::system_id].
    pub fn set_system_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.system_id = v.into();
        self
    }

    /// Sets the value of [account_id][crate::model::PosixAccount::account_id].
    pub fn set_account_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.account_id = v.into();
        self
    }

    /// Sets the value of [operating_system_type][crate::model::PosixAccount::operating_system_type].
    pub fn set_operating_system_type<T: std::convert::Into<crate::model::OperatingSystemType>>(
        mut self,
        v: T,
    ) -> Self {
        self.operating_system_type = v.into();
        self
    }

    /// Sets the value of [name][crate::model::PosixAccount::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }
}

impl wkt::message::Message for PosixAccount {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.oslogin.common.PosixAccount"
    }
}

/// The SSH public key information associated with a Google account.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct SshPublicKey {
    /// Public key text in SSH format, defined by
    /// [RFC4253](https://www.ietf.org/rfc/rfc4253.txt) section 6.6.
    pub key: std::string::String,

    /// An expiration time in microseconds since epoch.
    pub expiration_time_usec: i64,

    /// Output only. The SHA-256 fingerprint of the SSH public key.
    pub fingerprint: std::string::String,

    /// Output only. The canonical resource name.
    pub name: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl SshPublicKey {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [key][crate::model::SshPublicKey::key].
    pub fn set_key<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.key = v.into();
        self
    }

    /// Sets the value of [expiration_time_usec][crate::model::SshPublicKey::expiration_time_usec].
    pub fn set_expiration_time_usec<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
        self.expiration_time_usec = v.into();
        self
    }

    /// Sets the value of [fingerprint][crate::model::SshPublicKey::fingerprint].
    pub fn set_fingerprint<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.fingerprint = v.into();
        self
    }

    /// Sets the value of [name][crate::model::SshPublicKey::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }
}

impl wkt::message::Message for SshPublicKey {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.oslogin.common.SshPublicKey"
    }
}

/// The operating system options for account entries.
///
/// # Working with unknown values
///
/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
/// additional enum variants at any time. Adding new variants is not considered
/// a breaking change. Applications should write their code in anticipation of:
///
/// - New values appearing in future releases of the client library, **and**
/// - New values received dynamically, without application changes.
///
/// Please consult the [Working with enums] section in the user guide for some
/// guidelines.
///
/// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum OperatingSystemType {
    /// The operating system type associated with the user account information is
    /// unspecified.
    Unspecified,
    /// Linux user account information.
    Linux,
    /// Windows user account information.
    Windows,
    /// If set, the enum was initialized with an unknown value.
    ///
    /// Applications can examine the value using [OperatingSystemType::value] or
    /// [OperatingSystemType::name].
    UnknownValue(operating_system_type::UnknownValue),
}

#[doc(hidden)]
pub mod operating_system_type {
    #[allow(unused_imports)]
    use super::*;
    #[derive(Clone, Debug, PartialEq)]
    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
}

impl OperatingSystemType {
    /// Gets the enum value.
    ///
    /// Returns `None` if the enum contains an unknown value deserialized from
    /// the string representation of enums.
    pub fn value(&self) -> std::option::Option<i32> {
        match self {
            Self::Unspecified => std::option::Option::Some(0),
            Self::Linux => std::option::Option::Some(1),
            Self::Windows => std::option::Option::Some(2),
            Self::UnknownValue(u) => u.0.value(),
        }
    }

    /// Gets the enum value as a string.
    ///
    /// Returns `None` if the enum contains an unknown value deserialized from
    /// the integer representation of enums.
    pub fn name(&self) -> std::option::Option<&str> {
        match self {
            Self::Unspecified => std::option::Option::Some("OPERATING_SYSTEM_TYPE_UNSPECIFIED"),
            Self::Linux => std::option::Option::Some("LINUX"),
            Self::Windows => std::option::Option::Some("WINDOWS"),
            Self::UnknownValue(u) => u.0.name(),
        }
    }
}

impl std::default::Default for OperatingSystemType {
    fn default() -> Self {
        use std::convert::From;
        Self::from(0)
    }
}

impl std::fmt::Display for OperatingSystemType {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
        wkt::internal::display_enum(f, self.name(), self.value())
    }
}

impl std::convert::From<i32> for OperatingSystemType {
    fn from(value: i32) -> Self {
        match value {
            0 => Self::Unspecified,
            1 => Self::Linux,
            2 => Self::Windows,
            _ => Self::UnknownValue(operating_system_type::UnknownValue(
                wkt::internal::UnknownEnumValue::Integer(value),
            )),
        }
    }
}

impl std::convert::From<&str> for OperatingSystemType {
    fn from(value: &str) -> Self {
        use std::string::ToString;
        match value {
            "OPERATING_SYSTEM_TYPE_UNSPECIFIED" => Self::Unspecified,
            "LINUX" => Self::Linux,
            "WINDOWS" => Self::Windows,
            _ => Self::UnknownValue(operating_system_type::UnknownValue(
                wkt::internal::UnknownEnumValue::String(value.to_string()),
            )),
        }
    }
}

impl serde::ser::Serialize for OperatingSystemType {
    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        match self {
            Self::Unspecified => serializer.serialize_i32(0),
            Self::Linux => serializer.serialize_i32(1),
            Self::Windows => serializer.serialize_i32(2),
            Self::UnknownValue(u) => u.0.serialize(serializer),
        }
    }
}

impl<'de> serde::de::Deserialize<'de> for OperatingSystemType {
    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        deserializer.deserialize_any(wkt::internal::EnumVisitor::<OperatingSystemType>::new(
            ".google.cloud.oslogin.common.OperatingSystemType",
        ))
    }
}
